from app.services.business.gaolu_diagnose.ind.abstract_ind import AbstractInd


class CG_LT_GL_GL04_DWDB(AbstractInd):

    def get_name(self):
        return "CG_LT_GL_GL04_DWDB"

    def get_sql(self, params) -> str:
        sql_DWDB = """      
        	    SELECT mean(value) AS CG_LT_GL_GL04_DWDB   FROM "CG_LT_GL_GL04_DWDB" where time > '{dt_start_tz}' and time < '{dt_end_tz}'        
                       """.format(**params)
        return sql_DWDB

    @AbstractInd.cache_wrapper
    def get_result(self):
        sql = self.get_sql(self.params)
        client = self.influx_client
        result_set = list(client.query(sql))
        value = self.get_influx_result(result_set, "CG_LT_GL_GL04_DWDB")
        return round(value, 2)
